import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:online_study/theme/colors.dart';
import 'package:online_study/theme/size.dart';

//签到
class SignInPage extends StatefulWidget {
  @override
  _SignInPageState createState() => _SignInPageState();
}

class _SignInPageState extends State<SignInPage> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(
          horizontal: ThemeSize.width9, vertical: ThemeSize.height6),
      padding: EdgeInsets.only(
          left: ThemeSize.width19,
          right: ThemeSize.width19,
          top: ThemeSize.width19,
          bottom: ThemeSize.height8),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(ThemeSize.height8),
        color: ThemeColor.colorWhite,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text("已连续签到1天",
              style: TextStyle(
                  color: ThemeColor.color333333,
                  fontSize: ThemeSize.sp16,
                  fontWeight: FontWeight.bold)),
          Container(
            margin: EdgeInsets.only(top: ThemeSize.height8),
            child: Text(
              "每日签到有奖励",
              style: TextStyle(
                  color: ThemeColor.color999999, fontSize: ThemeSize.sp12),
            ),
          ),
          Wrap(
            children: [
              _buildItem(true, "第一天", "+1"),
              _buildItem(false, "第二天", "+1"),
              _buildItem(false, "第三天", "+2"),
              _buildItem(false, "第四天", "+2"),
              _buildItem(false, "第五天", "+3"),
              _buildItem(false, "第六天", "+3"),
              _buildItem(false, "第七天", "+5"),
            ],
          ),
          Container(
            alignment: Alignment.center,
            width: double.infinity,
            child: CupertinoButton(
              color: ThemeColor.colorF2F2F2,
              padding: EdgeInsets.symmetric(
                  vertical: ThemeSize.height8, horizontal: ThemeSize.width19),
              borderRadius: BorderRadius.circular(ThemeSize.height18),
              child: Text("已签到",
                  style: TextStyle(
                      color: ThemeColor.color999999, fontSize: ThemeSize.sp13)),
              onPressed: () {
                print("object");
              },
            ),
          )
        ],
      ),
    );
  }

  Widget _buildItem(bool sign, String day, String integral) {
    if (sign) {
      return Container(
        margin:
            EdgeInsets.only(right: ThemeSize.width9, top: ThemeSize.height16),
        child: Column(
          children: [
            Container(
              height: ThemeSize.height36,
              width: ThemeSize.height36,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: ThemeColor.colorFF804C,
                shape: BoxShape.circle,
              ),
              child: Icon(Icons.check,
                  size: ThemeSize.width12, color: ThemeColor.colorWhite),
            ),
            Container(
              margin: EdgeInsets.only(top: ThemeSize.height10),
              child: Text(day,
                  style: TextStyle(
                      color: ThemeColor.colorFF804C, fontSize: ThemeSize.sp12)),
            )
          ],
        ),
      );
    } else {
      return Container(
        margin:
            EdgeInsets.only(right: ThemeSize.width9, top: ThemeSize.height16),
        child: Column(
          children: [
            Container(
              height: ThemeSize.height36,
              width: ThemeSize.height36,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: ThemeColor.colorF2F2F2,
                shape: BoxShape.circle,
              ),
              child: Text(integral,
                  style: TextStyle(
                      color: ThemeColor.color999999, fontSize: ThemeSize.sp13)),
            ),
            Container(
              margin: EdgeInsets.only(top: ThemeSize.height10),
              child: Text(day,
                  style: TextStyle(
                      color: ThemeColor.color808080, fontSize: ThemeSize.sp12)),
            )
          ],
        ),
      );
    }
  }
}
